package org.example.service.impl;

import org.example.Dao.UserDao;
import org.example.pojo.User;
import org.example.service.UserService;

import java.util.Set;

/**
 * @author LiYa
 * @version 1.0
 * @className UserServiceImpl
 * description TODO
 * @since 2020/9/15 13:39
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao;

    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public Set<User> getAll() {
        return (Set<User>) userDao.queryAll();
    }

    @Override
    public boolean addOne(User user) {
        int result = userDao.insertByUser(user);
        return result>0;
    }

    @Override
    public boolean removeOne(User user) {
        int result = userDao.deleteByUser(user.getUserId());
        return result>0;
    }

    @Override
    public boolean modifyOne(User user) {
        int result = userDao.updateByUser(user);
        return result>0;
    }
}
